<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Write session data</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sessionhandler.read.html">SessionHandler::read</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div>
 <div class="up"><a href="class.sessionhandler.html">SessionHandler</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sessionhandler.write" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SessionHandler::write</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0)</p><p class="refpurpose"><span class="refname">SessionHandler::write</span> &mdash; <span class="dc-title">Write session data</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sessionhandler.write-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>SessionHandler::write</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$session_id</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$session_data</code></span>
   )</div>

  <p class="para rdfs-comment">
   Writes the session data to the session storage. Called by normal PHP shutdown, by
   <span class="function"><a href="function.session-write-close.html" class="function">session_write_close()</a></span>, or when <span class="function"><a href="function.session-register-shutdown.html" class="function">session_register_shutdown()</a></span> fails.
   PHP will call <span class="function"><a href="sessionhandler.close.html" class="function">SessionHandler::close()</a></span> immediately after this method returns.
  </p>
  <p class="para">
   This method wraps the internal PHP save handler defined in the
   <a href="session.configuration.html#ini.session.save-handler" class="link">session.save_handler</a> ini setting that was set
   before this handler was set by <span class="function"><a href="function.session-set-save-handler.html" class="function">session_set_save_handler()</a></span>.
  </p>
  <p class="para">
   If this class is extended by inheritiance, calling the parent <em><code class="parameter">write</code></em> method will invoke the
   wrapper for this method and therefor invoke the associated internal callback.  This allows this method to be
   overidden and or intercepted and filtered (for example, encrypting the <em><code class="parameter">$data</code></em> value
   before sending it to the parent <em><code class="parameter">write</code></em> method).
  </p>
  <p class="para">
   For more information on what this method is expected to do, please refer to the documentation
   at <span class="function"><a href="sessionhandlerinterface.write.html" class="function">SessionHandlerInterface::write()</a></span>.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-sessionhandler.write-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">session_id</code></em></dt>

    <dd>

     <p class="para">
      The session id.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">session_data</code></em></dt>

    <dd>

     <p class="para">
      The encoded session data.  This data is the result of the PHP internally encoding the <var class="varname"><var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var></var> superglobal to a serialized
      string and passing it as this parameter.  Please note sessions use an alternative serialization method.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-sessionhandler.write-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   会话存储的返回值（通常成功返回 0，失败返回 1）。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-sessionhandler.write-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
     The <a href="session.configuration.html#ini.session.serialize-handler" class="link">session.serialize_handler</a>
     configuration directive.
    </li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sessionhandler.read.html">SessionHandler::read</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div>
 <div class="up"><a href="class.sessionhandler.html">SessionHandler</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
